#include "date.h"
#include <gtest/gtest.h>

// Exercise 2.1
// Remove this test after inspecting the output.
// Tests which require manual verification should not be lumped
// with tests which are automatically verified!
//TEST(Date, dateHasUninitialisedState) {
//	Date today;
//	printDate(today);
//}

TEST(Date, validDateCanBeCreated) {
	Date heritage_day(24, September, 2000);
	EXPECT_EQ(24, heritage_day.day());
	EXPECT_EQ(September, heritage_day.month());
	EXPECT_EQ(2000, heritage_day.year());
}

// Exercise 2.2
// Supply additional tests for the constructor here, which
// verify that an exception is thrown when an attempt is made
// to construct an invalid date. Think carefully about which
// invalid dates to test.

TEST (Date, exceptionThrownWhenInvalidDate)
{
    //check for a negative date
    EXPECT_THROW({Date invalid_date1(-1, April, 2001);},wordNegOrZero);
    //check for date over 31
    EXPECT_THROW({Date invalid_date1(40, April, 2001);},wordTooLarge);
}

// Exercise 2.3
TEST(Date, identicalDatesAreEqual) {
    Date date_1(1, January, 2000);
    Date date_2(1, January, 2000);

    EXPECT_TRUE(date_1 == date_2);
}

// Supply at least three additional tests for
// the equality operator here, to ensure that
// it is working correctly.
TEST(Date, nonIdenticalDatesAreNotEqual )
{
    Date date_1(10, March, 2010);
    Date date_2(7, September, 1989);

    EXPECT_FALSE(date_1 == date_2);
}

TEST(Date, oneSimilarityBetweenDatesAreNotEqual)
{
    Date date_1(10, March, 2008);
    Date date_2(10, March, 1998);

    EXPECT_FALSE(date_1 == date_2);
}

TEST(Date, partiallyIdenticalDatesAreNotEqual )
{
    Date date_1(10, September, 2010);
    Date date_2(7, September, 2010);

    EXPECT_FALSE(date_1 == date_2);
}

// Exercise 2.4
// Provide tests for a new member function of the Date class
// which will increase the date by one day.
TEST( Date, canIncreaseDateByOneDay )
{
    Date date_1( 2, March, 2011 );
    date_1.increaseDateByOne();
    Date date_2( 3, March, 2011);
    EXPECT_TRUE( date_1 == date_2);

}

TEST( Date, canIncreaseDateToNextMonth )
{
    Date date_1( 31, March, 2011 );
    date_1.increaseDateByOne();
    Date date_2( 1, April, 2011);
    EXPECT_TRUE( date_1 == date_2);
}

TEST( Date, canIncreaseDateToNextYear )
{
    Date date_1( 31, December, 2000 );
    date_1.increaseDateByOne();
    Date date_2( 1, January, 2001);
    EXPECT_TRUE( date_1 == date_2);
}

TEST( Date, canHandleLeapYear )
{
    Date date1( 28, February, 2000);
    date1.increaseDateByOne();
    Date date2( 29, February, 2000);
    EXPECT_TRUE( date1 == date2 );
}

// Exercise 2.5
// Write tests for the new default constructor and the
// setDefaultDate method.
TEST( Date, defaultConstructorUsesDefaultDate )
{
    Date date1;
    Date defaultDate( 1, January, 1900);
    EXPECT_TRUE( date1 == defaultDate );
}

TEST( Date, clientCanSetDafaultDate )
{
    Date::setDefaultDate(8, September, 2000);
    Date date1( 8, September, 2000);
    Date newDefaultDate;
    EXPECT_TRUE( date1 == newDefaultDate );
}



